# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=yazi
pkgver=0.2.5
pkgrel=0
pkgdesc="Blazing fast terminal file manager written in Rust, based on async I/O"
url="https://yazi-rs.github.io"
arch="all"
license="MIT"
makedepends="
	cargo
	cargo-auditable
	lua5.4-dev
"
subpackages="
	$pkgname-doc
	$pkgname-cli
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/sxyazi/yazi/archive/refs/tags/v$pkgver.tar.gz
	system-lua.patch
"
options="net"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	YAZI_GEN_COMPLETIONS=true cargo auditable build --release --frozen --workspace --no-default-features
}

check() {
	cargo test --frozen --workspace --no-default-features
}

package() {
	install -Dm755 target/release/yazi "$pkgdir"/usr/bin/yazi
	install -Dm644 yazi-boot/completions/yazi.bash "$pkgdir"/usr/share/bash-completion/completions/yazi
	install -Dm644 yazi-boot/completions/yazi.fish "$pkgdir"/usr/share/fish/vendor_completions.d/yazi.fish
	install -Dm644 yazi-boot/completions/_yazi "$pkgdir"/usr/share/zsh/site-functions/_yazi
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

cli() {
	pkgdesc="$pkgdesc - CLI"
	depends="yazi=$pkgver-r$pkgrel"

	install -Dm755 "$builddir"/target/release/ya "$subpkgdir"/usr/bin/ya
}

sha512sums="
25228725f7ba9a769a3b699d86bd747d72363be132855bbcfd7ced4e31bd7d86a2efbcef83eb49439727c651a95eb95f000954175f1d6cdbd7b40fbeaa49c250  yazi-0.2.5.tar.gz
5255ffc371017055f5cdf4ef5eee52bd5879fc647d84f39323a43244275e397f996267417c29eea70f7f15d18b456143a28a14e4973cf4832854d4fc20f692ae  system-lua.patch
"
